<template>
	<div>
		<el-switch
			style="display: block"
			v-model="commitWWW"
			active-color="#13ce66"
			inactive-color="#ff4949"
			active-text="www---提交审核"
			inactive-text="审核通过"
			@change="changeWWWStatus"
		>
		</el-switch>
		<el-switch
			style="display: block;margin-top: 20px;"
			v-model="commitRelease"
			active-color="#13ce66"
			inactive-color="#ff4949"
			active-text="release---提交审核"
			inactive-text="审核通过"
			@change="changeReleaseStatus"
		>
		</el-switch>

	</div>
</template>

<script>
import { api } from "@/api/api.js";

export default {
	data () {
		return {
			commitWWW: false,
			commitRelease: false
		};
	},
	created () {
		this.getCommitWWWStatus()
		this.getCommitReleaseStatus()
	},
	methods: {
		getCommitWWWStatus() {
			this.http
        .get(api.getShowWWWStatus)
        .then(({ data }) => {
					console.log('get: ', data)
					this.commitWWW = data.showStatus === 1 ? true : false
        })
		},
		getCommitReleaseStatus() {
			this.http
        .get(api.getShowReleaseStatus)
        .then(({ data }) => {
					console.log('get: ', data)
					this.commitRelease = data.showStatus === 1 ? true : false
        })
		},
		changeWWWStatus(status) {
			this.http
        .post(api.updateShowWWWDragonInfo, { showStatus: status ? 1 : 0 })
        .then(({ data }) => {
					console.log('post: ', data)
					this.getCommitWWWStatus()
        })
		},
		changeReleaseStatus(status) {
			this.http
        .post(api.updateShowReleaseDragonInfo, { showStatus: status ? 1 : 0 })
        .then(({ data }) => {
					console.log('post: ', data)
					this.getCommitReleaseStatus()
        })
		}
	}
}
</script>

<style lang="css" scoped>

</style>